package com.pdd.service.impl;

import com.pdd.beans.Address;
import com.pdd.dao.AddressMapper;
import com.pdd.service.AddressService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService {

    @Autowired
    @Setter
    private AddressMapper addressMapper;

    /**
     * 添加地址信息
     *
     * @param address
     * @return
     */
    public boolean addAddress(Address address) {
        return addressMapper.insertAddress(address)>0;
    }

    /**
     * 删除地址信息
     *
     * @param id
     * @return
     */
    public boolean delAddress(int id) {
        return addressMapper.deleteAddress(id)>0;
    }

    /**
     * 修改用户信息
     *
     * @param address
     * @return
     */
    public boolean uplAddress(Address address) {
        return addressMapper.updateAddress(address)>0;
    }

    /**
     * 查询所有地址信息
     *
     * @return
     */
    public List<Address> getAddress() {
        return addressMapper.selectAddress();
    }

    /**
     * 根据ID查询地址信息
     *
     * @param u_id
     * @return
     */
    public Address getById(int u_id) {
        return addressMapper.selectById(u_id);
    }
}
